package com.cw.jeeyt.dao.impl.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.api.ApiFacadeModuleInfoDao;
import com.cw.jeeyt.dao.mapper.api.ApiFacadeModuleInfoMapper;
import com.cw.jeeyt.dao.model.api.ApiFacadeModuleInfoDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * api接口文档所在项目模块 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class ApiFacadeModuleInfoDaoImpl implements ApiFacadeModuleInfoDao {
    @Autowired
    private ApiFacadeModuleInfoMapper apiFacadeModuleInfoMapper;

    /**
     * 新增api接口文档所在项目模块
     *
     * @param apiFacadeModuleInfo
     * @return 整数
     */
    public Integer insert(ApiFacadeModuleInfoDo apiFacadeModuleInfo) {
        return apiFacadeModuleInfoMapper.insert(apiFacadeModuleInfo);
    }

    /**
     * 新增api接口文档所在项目模块不为空的字段
     *
     * @param apiFacadeModuleInfo
     * @return 整数
     */
    public Integer insertSelective(ApiFacadeModuleInfoDo apiFacadeModuleInfo) {
        return apiFacadeModuleInfoMapper.insertSelective(apiFacadeModuleInfo);
    }

    /**
     * 删除api接口文档所在项目模块
     *
     * @param apiFacadeModuleInfo
     */
    public void delete(ApiFacadeModuleInfoDo apiFacadeModuleInfo) {
        apiFacadeModuleInfoMapper.delete(apiFacadeModuleInfo);
    }

    /**
     * 修改api接口文档所在项目模块不为null的字段
     *
     * @param apiFacadeModuleInfo
     */
    public void updateSelective(ApiFacadeModuleInfoDo apiFacadeModuleInfo) {
        apiFacadeModuleInfoMapper.updateSelective(apiFacadeModuleInfo);
    }

    /**
     * 修改api接口文档所在项目模块
     *
     * @param apiFacadeModuleInfo
     */
    public void update(ApiFacadeModuleInfoDo apiFacadeModuleInfo) {
        apiFacadeModuleInfoMapper.update(apiFacadeModuleInfo);
    }

    /**
     * 根据主键查询api接口文档所在项目模块
     *
     * @return api接口文档所在项目模块
     */
    public ApiFacadeModuleInfoDo getById(Long id) {
        return apiFacadeModuleInfoMapper.getById(id);
    }

    /**
     * 查询所有api接口文档所在项目模块
     *
     * @return api接口文档所在项目模块集合
     */
    public List<ApiFacadeModuleInfoDo> queryApiFacadeModuleInfoList() {
        return apiFacadeModuleInfoMapper.queryApiFacadeModuleInfoList();
    }

    /**
     * 分页查询api接口文档所在项目模块
     *
     * @param apiFacadeModuleInfo 查询条件
     * @param startRow 开始条数
     * @param pageSize 每页长度
     * @return api接口文档所在项目模块集合
     */
    public PageInfo<ApiFacadeModuleInfoDo> queryByPage(ApiFacadeModuleInfoDo apiFacadeModuleInfo, Integer startRow,
        Integer pageSize, Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startRow, pageSize), pageSize);
        return new PageInfo<>(apiFacadeModuleInfoMapper.queryByPage(apiFacadeModuleInfo, order));
    }

    /**
     * 检查当前项目下模块是否已存在
     *
     * @param projectId
     * @param moduleCode
     * @return
     * @throws Exception
     */
    public ApiFacadeModuleInfoDo queryByProjectIdAndModuleCode(Long projectId, String moduleCode) {
        return apiFacadeModuleInfoMapper.queryByProjectIdAndModuleCode(projectId, moduleCode);
    }

    /**
     * 根据项目id查询模块信息
     *
     * @param projectId
     * @return
     * @throws Exception
     */
    public List<ApiFacadeModuleInfoDo> queryListByProjectId(Long projectId) {
        return apiFacadeModuleInfoMapper.queryListByProjectId(projectId);
    }

    /**
     * 根据模块编码查询模块信息
     *
     * @param moduleCodes
     * @return
     * @throws Exception
     */
    public List<ApiFacadeModuleInfoDo> queryListByModuleCodes(List<String> moduleCodes) {
        return apiFacadeModuleInfoMapper.queryListByModuleCodes(moduleCodes);
    }

    /**
     * 批量新增api接口文档所在项目模块
     *
     * @param moduleInfoList
     * @return 整数
     */
    public Integer insertBat(List<ApiFacadeModuleInfoDo> moduleInfoList) {
        return apiFacadeModuleInfoMapper.insertBat(moduleInfoList);
    }

}
